﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using DataAccessClasses;

namespace BOGolf
{
    class Comment
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _commentid = -99;
        private long _blogid = -99;
        private long _userid = -99;
        private DateTime _commentdate = Convert.ToDateTime("1/1/1800");
        private string _comments = "";
        private bool _isdeleted = false;

        public long commentid
        {
            get
            {
                return _commentid;
            }
            set
            {
                _commentid = value;
            }
        }
        public long blogid
        {
            get
            {
                return _blogid;
            }
            set
            {
                _blogid = value;
            }
        }
        public long userid
        {
            get
            {
                return _userid;
            }
            set
            {
                _userid = value;
            }
        }
        public DateTime commentdate
        {
            get
            {
                return _commentdate;
            }
            set
            {
                _commentdate = value;
            }
        }
        public string comments
        {
            get
            {
                return _comments;
            }
            set
            {
                _comments = value;
            }
        }
        public bool isdeleted
        {
            get
            {
                return _isdeleted;
            }
            set
            {
                _isdeleted = value;
            }
        }
        public long SaveRecords()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@commentid", commentid, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@blogid", blogid, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@userid", userid, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@commentdate", commentdate, DbType.DateTime, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@comments", comments, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5 };
                return DAC.Save("comment_save", dbparamcall);
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }

        public DataTable GetRecords(long commentid, long blogid, long userid, DateTime commentdate, string comments, bool isdeleted, string paraandor)
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@commentid", commentid, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@blogid", blogid, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@userid", userid, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@commentdate", commentdate, DbType.DateTime, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@comments", comments, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam6 = DAC.Parameter("@paraandor", paraandor, DbType.AnsiString, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5, dbparam6};
                DataTable dt1 = DAC.Select("comment_get", dbparamcall);    
                return dt1;
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }
    }
}
